#include <iostream>
using namespace std;
const int N = 200005;
int t, n;
int a[N];
int main(){
	cin >> t;
	while(t--){
		cin >> n;
        int a_max = 0;
		for (int i = 0; i < n; i++){
			cin >> a[i];
			if (a[i] > a_max)a_max = a[i];
		}
		if (a_max >= n) cout << a_max << endl;
		else cout << n << endl;
		
	}

    return 0;
}


